import { Component, OnInit } from '@angular/core';
import { DataService } from '../data.service';

@Component({
  selector: 'app-cityarea',
  templateUrl: './cityarea.page.html',
  styleUrls: ['./cityarea.page.scss'],
})
export class CityareaPage implements OnInit {
  hwlb = '';
  cityData: any[] = [];

  constructor(private ds: DataService) { }
  ngOnInit() {
    this.ds.geCityData().subscribe(res => {
      this.cityData = res;

    },
      error => {
        console.log(error);
      });
  }

  onCityChange(e) {
    const cityvalue = e.getValue();  //get city value
    console.log(cityvalue);
  }



  recPro(event) {
    if (event.length !== 0) {
      for (var i = 0; i < event.length; i++) {
        var data = event[i];
        if (this.hwlb === '') {
          this.hwlb = data.name + ','
        } else if (this.hwlb.indexOf(data.name) === -1) {
          this.hwlb += data.name + ',';
        }
      }
    }
    // alert("选中"+this.hwlb.TITLE);
    // console.log(`contact by edited id is ${event.cityId+'--'+event.countryId}`);
  }
}


